<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ question.question_text }}</title>
</head>
<body>
    <h2>{{ question.question_text }}</h2>
    <h4>发表于 {{ question.pub_date|date:'Y-m-d' }}</h4>
    <hr>
    <ul>
{#        {% for choice in choices %}#}
{#            <li>#}
{#            {{ choice.choice_text }}#}
{#            </li>#}
{#        {% endfor %}#}

        {% for choice in question.choice_set.all %}
            <li>
            {{ choice.choice_text }}
            </li>
        {% endfor %}
    </ul>


    <hr>

    <h2>表单投票</h2>
    <form action="{% url 'polls:polls-vote' question.id %}" method="post">
        {% csrf_token %}
        <!-- 知识点: fieldset 及 legend -->
        <fieldset>
            <legend>
                <h1>{{ question.question_text }}</h1>
            </legend>
            {% if error_message %}
                <p><strong>{{ error_message }}</strong></p>
            {% endif %}
            {% for choice in question.choice_set.all %}
                <!-- 知识点: django 模板for循环中 forloop 使用 -->
                <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
                <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label>
                <br>
            {% endfor %}
        </fieldset>
        <input type="submit" value="Vote投票">
    </form>
</body>
</html>